package com.ctshk.task.worker.processors;

import com.ctshk.common.dto.Result;
import com.ctshk.rpc.custom.dto.inquiry.InquiryInfoDTO;
import com.ctshk.rpc.custom.service.ICustomizedInquiryService;
import com.ctshk.rpc.visa.service.IVisaOrderService;
import com.github.kfcfans.powerjob.worker.core.processor.ProcessResult;
import com.github.kfcfans.powerjob.worker.core.processor.TaskContext;
import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
import com.github.kfcfans.powerjob.worker.log.OmsLogger;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 定时修改订单支付状态
 * com.ctshk.task.worker.processors.UpdateVisaOrderStatusProcessor
 *
 * @author 谢诗宏
 * @since 2021-2-1
 */
@Slf4j
@Component
public class UpdateVisaOrderStatusProcessor implements BasicProcessor {

    @DubboReference
    private IVisaOrderService visaOrderService;

    @Override
    public ProcessResult process(TaskContext context) throws Exception {

        OmsLogger omsLogger = context.getOmsLogger();
        visaOrderService.updateStatus();
        // 根据控制台参数判断是否成功
        boolean success = !"failed".equals(context.getJobParams());
        omsLogger.info("UpdateVisaOrderStatusProcessor finished process,success: .", success);
        return new ProcessResult(success, context + ": " + success);
    }

}
